package com.ryujung.linked_list.leetCode_83;
import com.ryujung.linked_list.node.ListNode;

/*
 * @lc app=leetcode.cn id=83 lang=java
 *
 * [83] 删除排序链表中的重复元素
 */

// @lc code=start
/**
 * Definition for singly-linked list. public class ListNode { int val; ListNode
 * next; ListNode() {} ListNode(int val) { this.val = val; } ListNode(int val,
 * ListNode next) { this.val = val; this.next = next; } }
 */
class Solution1 {
    public ListNode deleteDuplicates(ListNode head) {
        ListNode curNode = head;
        while (curNode != null) {
            int curNum = curNode.val;
            boolean isDuplicate = curNode.next != null && curNum == curNode.next.val;
            if (isDuplicate) {
                curNode.next = curNode.next.next;
            }else{
                curNode = curNode.next;
            }
        }
        return head;
    }
}
// @lc code=end
